import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { PackageApi } from '#/api/wedding/package';

import { z } from '#/adapter/form';
import {
    DICT_Wedding_TYPE,
    getDictOptions,
    getRangePickerDefaultProps,
} from '#/utils';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'packageId',
      label: '套餐ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入套餐ID',
      },
    },
    {
      fieldName: 'packageType',
      label: '套餐类型(BASIC/STANDARD/PREMIUM/LUXURY)',
      rules: 'required',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase(), 'string'),
        placeholder: '请选择套餐类型(BASIC/STANDARD/PREMIUM/LUXURY)',
      },
    },
    {
      fieldName: 'packageName',
      label: '套餐名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入套餐名称',
      },
    },
    {
      fieldName: 'serviceItems',
      label: '服务项列表(JSON)',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务项列表(JSON)',
      },
    },
    {
      fieldName: 'discountRate',
      label: '折扣率',
      component: 'Input',
      componentProps: {
        placeholder: '请输入折扣率',
      },
    },
    {
      fieldName: 'description',
      label: '套餐描述',
      component: 'RichTextarea',
    },
    {
      fieldName: 'isActive',
      label: '是否启用',
      component: 'Input',
      componentProps: {
        placeholder: '请输入是否启用',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'packageId',
      label: '套餐ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入套餐ID',
      },
    },
    {
      fieldName: 'packageType',
      label: '套餐类型(BASIC/STANDARD/PREMIUM/LUXURY)',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase(), 'string'),
        placeholder: '请选择套餐类型(BASIC/STANDARD/PREMIUM/LUXURY)',
      },
    },
    {
      fieldName: 'packageName',
      label: '套餐名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入套餐名称',
      },
    },
    {
      fieldName: 'serviceItems',
      label: '服务项列表(JSON)',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务项列表(JSON)',
      },
    },
    {
      fieldName: 'discountRate',
      label: '折扣率',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入折扣率',
      },
    },
    {
      fieldName: 'description',
      label: '套餐描述',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入套餐描述',
      },
    },
    {
      fieldName: 'isActive',
      label: '是否启用',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入是否启用',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<PackageApi.Package>['columns'] {
  return [
    {
      field: 'id',
      title: '',
      minWidth: 120,

    },
    {
      field: 'packageId',
      title: '套餐ID',
      minWidth: 120,

    },
    {
      field: 'packageType',
      title: '套餐类型(BASIC/STANDARD/PREMIUM/LUXURY)',
      minWidth: 120,

    },
    {
      field: 'packageName',
      title: '套餐名称',
      minWidth: 120,

    },
    {
      field: 'serviceItems',
      title: '服务项列表(JSON)',
      minWidth: 120,

    },
    {
      field: 'discountRate',
      title: '折扣率',
      minWidth: 120,

    },
    {
      field: 'description',
      title: '套餐描述',
      minWidth: 120,

    },
    {
      field: 'isActive',
      title: '是否启用',
      minWidth: 120,

    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

